#pragma once

#include "CBase.h"
class CHero;
class CPlayer;
#include "SGD Wrappers/SGD_Math.h"
#include "CNotePattern.h"

#include "CParticleManager.h"
#include "CAnimation.h"
#include "CLevel.h"
class CAnimationManager;

enum eUnitType{BASE_UNIT, RAT, CHILD, MENURAT};
enum State{FOLLOWING_PLAYER, WANDERING};
class CUnit : public CBase
{
	CNotePattern m_NotePattern;
	int m_nUnitType;
	tVector2D toPlayer;
	tVector2D travelingVec;
	int m_nDeathArea;

	float m_fPower;
	float m_fRange;
	float m_fSpeed;
	float m_fTimeElapsed;
	float m_fMaxInterest;
	float m_fCurrInterest;
	float m_fNoteTime;
	int m_nMaxHP;
	int m_nCurrHP;
	int m_nCost;
	bool m_bIsFlipped;
	bool m_bIsDead;
	tVector2D targetVec;
	int m_nState;
	float startX;
	float startY;
	float nextSpotX;
	float nextSpotY;
	CPlayer* m_pPlayer;
	CEmitter* pEmitter;
	int m_nChildHappy;
	int m_nRatHappy;

	Animations m_pUnit;
	CAnimationManager* m_pAnimate;

public:
	/////////////////////////////////////////////////
	//	Accessors/mutators
	float GetPower() {return m_fPower;}
	float GetRange() {return m_fRange;}
	float GetSpeed() {return m_fSpeed;}
	int GetMaxHP() {return m_nMaxHP;}
	int GetCurrHP() {return m_nCurrHP;}
	void SetPower(float Power) {m_fPower = Power;}
	void SetRange(float Range) {m_fRange = Range;}
	void SetMaxHP(int Max) {m_nMaxHP = Max;}
	void SetCurrHP(int Curr) {m_nCurrHP = Curr;}
	void SetCost(int Cost) {m_nCost = Cost;}
	void SetSpeed(float Speed) {m_fSpeed = Speed;}
	int GetCost() {return m_nCost;}
	int UnitType() const { return m_nUnitType; }
	void UnitType(int val) { m_nUnitType = val; }
	float MaxInterest() const { return m_fMaxInterest; }
	void MaxInterest(float val) { m_fMaxInterest = val; }
	float CurrInterest() const { return m_fCurrInterest; }
	void CurrInterest(float val) { m_fCurrInterest = val; }
	void SetNextSpotX(float X) {nextSpotX = X;}
	void SetNextSpotY(float Y) {nextSpotY = Y;}
	void SetStartX(float X)	{startX = X;}
	void SetStartY(float Y) {startY = Y;}
	int State() const { return m_nState; }
	void State(int val) { m_nState = val; }
	bool IsDead() const { return m_bIsDead; }
	void IsDead(bool val) { m_bIsDead = val; }
	int DeathLevel() const { return m_nDeathArea; }
	void DeathLevel(int val) { m_nDeathArea = val; }
	//
	////////////////////////////////////////////////

	CUnit();
	~CUnit();


	void Init(
		float fPosX, float fPosY, float fVelX, float fVelY, int nMaxHP, 
		int nCurHP, int nHeight, int nWidth, int nSpeed, int State, CHero* pHero);
	void Update(float fDelta);
	void Render();
	bool Collision(CBase* pBase);
	void HandleEvent(CEvent* pEvent);
	void Damage(int nDamage);
};